package com.app.aclass;

import android.content.Intent;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class HistoryActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_history);

        RecyclerView recyclerView = findViewById(R.id.recyclerView);
        //添加历史记录数据
        List<HistoryBean> mList = new ArrayList<>();
        mList.add(new HistoryBean(
                "2022/11/29 10:59:02 \n2022/11/29 10:59:02",
                "张三","男","1234567890000xxxx","项目管理部","张总"
        ));
        mList.add(new HistoryBean(
                "2022/11/29 10:59:02 \n2022/11/29 10:59:02",
                "李四","女","1234567890000xxxx","教学处","超级管理员"
        ));
        //创建适配器
        HistoryAdapter adapter = new HistoryAdapter(R.layout.item_history, mList);
        //设置垂直线性布局
        recyclerView.setLayoutManager(new LinearLayoutManager(HistoryActivity.this));
        //设置适配器
        recyclerView.setAdapter(adapter);
        //添加适配器布局点击事件
        adapter.addChildClickViewIds(R.id.item_ll);
        //点击事件监听
        adapter.setOnItemChildClickListener((adapter1, view, position) -> {
            startActivity(new Intent(HistoryActivity.this,AddActivity.class));
        });
    }
}